/**
Copyright 2011 Patrick Devaney

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <iostream>
using namespace std;

// The "library" that calculates B based on Y, X, and B
// I've implemented a simple way to do this without dealing
// with unknown variables (as C++ likes everything known)
long double calcmxyb(long double X, long double Y, long double B) {
// XPB is X + B
long double XPB, M;
// Simplifes

XPB = X + B;
// Then we do the simple algorithm equivalent of "removing Y
//from both sides", and "getting B on it's own"
M = Y / XPB;
return M;
}

// The function that does the I/O, which main.cpp uses
int calcmxybplugin(void) {
long double X, Y, B, M;
// Basic I/O
cout << "Y = MX + B" << endl;
cout << "What is the X coordinate you want to plug in?" << endl;
cin >> X;
cout << "What is the Y coordinate you want to plug in?" << endl;
cin >> Y;
cout << "What is the value of B?" << endl;
cin >> B;

M = calcmxyb(X, Y, B);

cout << "The value of M is:" << endl << M << endl;
}